var _util = require('util/util.js');

var _account_service = {
    checkLogin : function(resolve,reject){
        _util.request({
            url     : _util.getServerURL("account/get_login_account_info"),
            method  : 'POST',
            success : resolve,
            error   : reject,
        });
    },
    login : function(account,resolve,reject){
        _util.request({
            url     : _util.getServerURL("account/login"),
            data    : account,
            method  : 'POST',
            success : resolve,
            error   : reject,
        });
    },
    loginByCode : function(account,resolve,reject){
        _util.request({
            url     : _util.getServerURL("account/loginByCode"),
            data    : account,
            method  : 'POST',
            success : resolve,
            error   : reject,
        });
    },
    sendCode : function(memphone,resolve,reject){
        _util.request({
            url     : _util.getServerURL("signon/sendCode"),
            data    : memphone,
            method  : 'POST',
            success : resolve,
            error   : reject,
        });
    },
    loginByCode : function(account,resolve,reject){
        _util.request({
            url     : _util.getServerURL("account/loginByCode"),
            data    : account,
            method  : 'POST',
            success : resolve,
            error   : reject,
        });
    },
    logout : function(resolve,reject){
        _util.request({
            url     : _util.getServerURL("account/logout"),
            method  : 'POST',
            success : resolve,
            error   : reject,
        });
    },
    regist : function(account , resolve, reject){
        _util.request({
            url     : _util.getServerURL('account/accounts'),
            data    : account,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    editAccount : function(account , resolve, reject){
        _util.request({
            url     : _util.getServerURL('account/newAccount'),
            data    : account,
            method  : 'PUT',
            success : resolve,
            error   : reject
        });
    },
}

module.exports = _account_service;

